import re


def validate_color_format(color_text):
    # 匹配 "#xxxxxx" 格式的正则表达式
    hex_color_pattern = r'^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$'

    # 匹配 "rgb(xxx,xxx,xxx)" 格式的正则表达式
    rgb_color_pattern = r'^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$'

    if re.match(hex_color_pattern, color_text):
        return True
    else:
        return False


# 测试示例
color1 = "#D2F9D1"
color2 = "rgb(45,59,40)"
color3 = "#2B2B2B"

# print(validate_color_format(color1))  # 输出: True
# print(validate_color_format(color2))  # 输出: True
# print(validate_color_format(color3))  # 输出: False

